package donnees;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;

public class DB {
	public static DB ls = null;
	private Connection dbCon = null;

	public static DB getInstance() throws SQLException {
		if (ls == null) {
			ls = new DB();
		}
		return ls;
	}

	private void initConnection() throws SQLException {
		try {
			Class.forName("org.hsqldb.jdbcDriver");
			// TODO config et non en dur
			dbCon = DriverManager.getConnection(
					"jdbc:hsqldb:hsql://localhost/projetcardb", "sa", "");
		} catch (ClassNotFoundException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}

	}

	public Connection getConnection() throws SQLException {
		if (dbCon == null) {
			this.initConnection();
		}
		return this.dbCon;

	}
}
